﻿import { Injectable ,Inject}    from '@angular/core';
import 'rxjs/add/operator/toPromise';
import { Headers, Http , URLSearchParams ,RequestOptions,ResponseContentType} from '@angular/http';

import { CONFIG_API } from '../../tools/serivce/config/config';

@Injectable()
export class loginService{
    public headers = new Headers({
        'Content-Type': 'application/json',
        'Cache-Control': 'no-cache'
    });
    constructor(
        private http: Http,
        @Inject(CONFIG_API) private Url: string,
    ) { }


    loginFn(param){
        let _self = this;
        return _self.http.post(_self.Url + 'app/login',param,{ headers: this.headers})
        .toPromise().then( response => response.json() )
        .catch(_self.handleError);
    }

    private handleError(error: any){
        return Promise.reject(error.json());
    }
}

